package com.luozhili.rabbitmqlearningdemo.spring_demo.simple_demo;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 消费者（监听者）
 *
 */
@Component
public class Listener {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "topic_spring_learn_queue"),
            exchange = @Exchange(value = "topic_spring_learn_exchange",type = ExchangeTypes.TOPIC),
            key = "user.*"
    ))

    public void listen(String msg){
        System.out.println(" [x] 接收消息 '" + msg + "'");
    }
}
